package com.aco.party.service.system;

import com.aco.party.dao.custom.VisitDao;
import com.aco.party.model.po.Visit;
import com.aco.party.model.vo.VisitParam;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * Created by flying on 3/10/2016 0010.
 */
@Service
public class VisitService {
    @Resource
    private VisitDao visitDao;

    public Integer getCountByParam(VisitParam param){
        return visitDao.getCountByParam(param);
    }

    public List<Long> getTopByParam(VisitParam param){
        return visitDao.getTopByParam(param);
    }

    public Integer getTotal() {
        return visitDao.getTotal();
    }

    public void update(Visit visit) {
        visit.setUpdateTime(new Date());
        visitDao.updateByPrimaryKeySelective(visit);
    }

    public void add(Visit visit) {
        visit.setCreateTime(new Date());
        visitDao.insertSelective(visit);
    }

    public void delete(Long id) {
        visitDao.deleteByPrimaryKey(id);
    }

    public Visit getByPrimaryKey(Long id) {
        return visitDao.selectByPrimaryKey(id);
    }
}
